package top.hg.tool.modules.car.index;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.hg.tool.common.util.Assert;
import top.hg.tool.common.util.R;
import top.hg.tool.modules.car.person.LotteryPersonEntity;

import java.util.List;

/**
 * @Author: skh
 * @Date: 2019/7/30 10:34
 * @Description:
 */
@RestController
@RequestMapping("/car")
@Api(value = "指标管理")
@Slf4j
public class IndexController {

    @Autowired
    private IndexService indexService;

    @ApiOperation("一键查询中签情况")
    @GetMapping("/batchQueryIndex")
    public R batchQueryIndex(String openId) {
        Assert.isEmpty(openId, "openId不能为空");
        List<LotteryPersonEntity> lotteryPersonEntityList = indexService.batchQueryIndex(openId);
        return R.success(lotteryPersonEntityList);
    }

    @ApiOperation("查询个人指标")
    @GetMapping("/queryIndex")
    public R queryIndex(String query) {
        log.info("查询个人指标,参数:[{}]", query);
        List<IndexEntity> indexEntityList = indexService.queryIndex(query);
        return R.success(indexEntityList);
    }

    @ApiOperation("查询指定人员的个人指标")
    @GetMapping("/queryIndexByPersonId")
    public R queryIndexByPersonId(Integer id) {
        List<IndexEntity> indexEntityList = indexService.queryIndexByPersonId(id);
        return R.success(indexEntityList);
    }

}
